package com.example.testapp;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
 
public class FragmentOne extends Fragment {
 
	List<Message> messageList = new ArrayList<Message>();
	HashMap<String, Message> map = new HashMap<String, Message>();
	CustomAdapter mCustomAdapter;
	
    public static Fragment newInstance(Context context) {
        FragmentOne f = new FragmentOne();
 
        return f;
    }
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_one, null);
        PopulateMessageList();
        
        Toast t = Toast.makeText(getActivity().getApplicationContext(), "listview plix", Toast.LENGTH_SHORT);
        t.show();
        //ListView listView = (ListView) getView().findViewById(R.id.listView);
        //SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), (List<? extends Map<String, ?>>) map, android.R.layout.simple_list_item_1,
        		//new String[] {"test"}, new int[] {android.R.id.text1});
        
        //mCustomAdapter = new CustomAdapter(this.getActivity());
        //listView.setAdapter(mCustomAdapter);
        
        return root;
    }    

	private void PopulateMessageList(){
    	messageList.add(new Message("Test1"));
    	messageList.add(new Message("Test2"));
    	messageList.add(new Message("Test3"));
    	messageList.add(new Message("Test4"));
    	for (Message message : messageList) {
        	map.put(message.m_message, message);
        }
    }
 
}
